<?php /* Smarty version 2.6.18, created on 2009-10-22 01:03:02
         compiled from orsfishermanlist.tpl */ ?>
<div id="divfishermanreason" style="position:absolute;background-color:#fff;width:500px;z-index: 1002;display:none;"></div>
<table class="popup" border="0" cellspacing=0 cellpadding=0>
	<input type="hidden" name="podetailid" value="<?php echo $this->_tpl_vars['podetailid']; ?>
">
	<tr><td><div class="pop">
		<div class="top_pop"><img src="/app/default/www/images/top_left_pop.jpg" /></div> 
		<div id="drag_bar"><h2 class="pop_h2">&nbsp;&nbsp;Fisherman</h2></div>
		<div class="content">			
			<table border="0" width="100%">
				<tr>
					<td width="40%">Firsherman</td>
					<td width="10%">Quantity</td>
					<td width="10%">DOA</td>
					<td width="10%">Reject</td>
					<td width="20%">Reason</td>
				</tr>
				<tr><td colspan=5><hr></td></tr>
			</table>
			<div id="scroll_content" style="overflow: auto;height:200px;">
				<table border="0" width="100%">									
					<?php $_from = $this->_tpl_vars['fisherValue']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['item']):
?>
					<?php $this->assign('fisherid', $this->_tpl_vars['item']['fisher_id']); ?>
					<tr>
						<td width="45%"><?php echo $this->_tpl_vars['item']['last_name']; ?>
, <?php echo $this->_tpl_vars['item']['first_name']; ?>
</td>
						<td width="13%" align="center"><input type="text" name="fishermanqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]" style="width:30px" value="<?php echo $this->_tpl_vars['selectedvalue'][$this->_tpl_vars['fisherid']]['qty']; ?>
" id="fishermanqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]"></td>
						<td width="13%" align="center"><input type="text" name="fishermandoaqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]" style="width:30px" value="<?php echo $this->_tpl_vars['selectedvalue'][$this->_tpl_vars['fisherid']]['doa']; ?>
" id="fishermandoaqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]" ></td>
						<td width="10%" align="center"><input type="text" name="fishermanrejectqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]" style="width:30px" value="<?php echo $this->_tpl_vars['selectedvalue'][$this->_tpl_vars['fisherid']]['reject']; ?>
" id="fishermanrejectqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]"></td>
						<td  width="20%"><input type="button" value="Reason" onclick="openFishermanReason('<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
')" ></td>
						<input type="hidden" name="fishermanreason[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]" id="fishermanreason[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]" value="<?php echo $this->_tpl_vars['selectedvalue'][$this->_tpl_vars['fisherid']]['reject']; ?>
">
					</tr>
					<?php endforeach; endif; unset($_from); ?>
					<tr><td height="10"></td></tr>
				</table>
			</div>
			<div align="center"><input type="button" value="Close" onclick="popup('divfisherman');">&nbsp;<input type="button" value="Save" onclick="saveorsfisherman();"></div>
		</div>
		<div class="btm_pop"><img src="/app/default/www/images/btm_left_pop.jpg"  alt="" />
	</div></td></tr>
</table>
<script language="javascript">
<?php echo '
	function saveorsfisherman() {
		var tqty = 0;
		var tdoa = 0;
		var treject = 0;
		var treason = 0;
		'; ?>

		<?php $_from = $this->_tpl_vars['fisherValue']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['item']):
?>
			if(document.getElementById('fishermanqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]').value > 0 ) {
				
				tqty = tqty + parseInt(document.getElementById('fishermanqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]').value);
				
			}
			if (document.getElementById('fishermandoaqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]').value > 0 ) {
				tdoa = tdoa + parseInt(document.getElementById('fishermandoaqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]').value);
			}
			if(document.getElementById('fishermanrejectqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]').value > 0) {
				treject = treject + parseInt(document.getElementById('fishermanrejectqty[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]').value);
				treason = treason + parseInt(document.getElementById('fishermanreason[<?php echo $this->_tpl_vars['item']['fisher_id']; ?>
]').value);
			}
			
		<?php endforeach; endif; unset($_from); ?>
		<?php echo '
	
		//if(tqty > 0) {
			document.getElementById(\'received['; ?>
<?php echo $this->_tpl_vars['podetailid']; ?>
<?php echo ']\').value = tqty;
		//}
		//if (tdoa > 0) {
			document.getElementById(\'doa['; ?>
<?php echo $this->_tpl_vars['podetailid']; ?>
<?php echo ']\').value = tdoa;
		//}
		//if(treject > 0) {
			document.getElementById(\'reject['; ?>
<?php echo $this->_tpl_vars['podetailid']; ?>
<?php echo ']\').value = treject;
			document.getElementById(\'reasonqty['; ?>
<?php echo $this->_tpl_vars['podetailid']; ?>
<?php echo ']\').value = treject;
		//}
		
		if(tqty  > 0 || tdoa > 0 || treject > 0) {
			document.getElementById(\'fisherman['; ?>
<?php echo $this->_tpl_vars['podetailid']; ?>
<?php echo ']\').value = 1;
		} else {
			document.getElementById(\'fisherman['; ?>
<?php echo $this->_tpl_vars['podetailid']; ?>
<?php echo ']\').value = 0;
			document.getElementById(\'received['; ?>
<?php echo $this->_tpl_vars['podetailid']; ?>
<?php echo ']\').value = document.getElementById(\'origvalue['; ?>
<?php echo $this->_tpl_vars['podetailid']; ?>
<?php echo ']\').value;
		}
		
		if(treject == treason) {
		
			doajaxAction("/account/saveorsfisherman",1,\'detail\',document.getElementById(\'mainForm\'),true);
			popup(\'divfisherman\');
		} else {
			alert("Reject quantity and Reason is not equal ...");
		}
	}
	
	function openFishermanReason(fisherid){
	
		var qty = document.getElementById(\'fishermanrejectqty[\'+ fisherid + \']\').value;	
		if(qty > 0) {
					doajaxAction("/account/saveorsfisherman",1,\'detail\',document.getElementById(\'mainForm\'),true);						openWindow("/account/fishermanrejectReason/fisherid/"+fisherid+"/qty/"+qty+"/podetailid/'; ?>
<?php echo $this->_tpl_vars['podetailid']; ?>
<?php echo '",\'rejectreason\',470,290, \'scrollbars=yes\');
		} else {
			alert(\'Please put reject quantity\');
		}
	}
'; ?>

</script>
		